package factory.simplefactory;

/**
 * @auther: Steven
 * @created： 2018/2/9 18:35
 * Description：交通工具的简单工厂
 */
public class VehicleSimpleFactory {
    public static final String VEHICLE_TYPE_CAR = "car";
    public static final String VEHICLE_TYPE_LIMOUSINE = "limousine";
    public static final String VEHICLE_TYPE_TRUNK = "trunk";

    public static IVehicle newInstanceVehicle(String vehicleType, String... args) {
        switch (vehicleType) {
            case VEHICLE_TYPE_CAR:
                if (args != null) {
                    return new Car(args[0]);
                }
                return new Car();
            case VEHICLE_TYPE_LIMOUSINE:
                if (args != null) {
                    return new Limousine(args[0]);
                }
                return new Limousine();
            case VEHICLE_TYPE_TRUNK:
                if (args != null) {
                    return new Trunk(args[0]);
                }
                return new Trunk();
            default:
                return new Car();
        }
    }
}
